import sqlite3

j = 0
device_counter = {}
for i in range(0, 1533):
    with open('temp{}'.format(i), 'r', encoding='utf8') as f:
        for line in f:
            line = line.replace('\n', '')
            if line not in device_counter:
                device_counter[line] = 0
            device_counter[line] += 1
        print('{} finish'.format(f.name))

print('finish read, start write')
with open('device_counter', 'w', encoding='utf8') as f:
    for device, count in device_counter.items():
        line = '{}={}\n'.format(device, count)
        f.write(line)
print('finish write')
